package com.sky.mapper;

import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     *根据菜品ID查询套餐ID
     * @param dishId
     * @return
     */
    @Select("select setmeal_id from setmeal_dish where dish_id=#{dishId}")
    List<Long> getSetmealIdByDishId(Long dishId);

    /**
     * 根据套餐ID查询菜品ID
     * @param setmealId
     */
    @Select("select dish_id from setmeal_dish where setmeal_id=#{setmealId}")
    List<Long> getDishIdBySetmealId(Long setmealId);

    /**
     * 修改套餐菜品关系
     * @param dish
     */
    void update(SetmealDish dish);

    /**
     * 根据套餐ID查询菜品
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id=#{setmealId}")
    List<SetmealDish> queryBySetmealId(Long setmealId);

    /**
     * 新增套餐菜品关系
     * @param setmealDishes
     */
    void insert(List<SetmealDish> setmealDishes);

    /**
     * 根据ID集合删除套餐菜品关系
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id=#{setmealId}")
    void delete(Long setmealId);

//    /**
//     * 根据套餐ID查询菜品
//     * @param id
//     * @return
//     */
//    List<DishItemVO> getBySetmealId(Long id);
}
